package com.yf.yfwebview.command

import android.content.ComponentName
import android.content.Intent
import com.android.baselibrary.app.MainApplication
import com.google.auto.service.AutoService
import com.google.gson.Gson

@AutoService(Command::class)
class OpenActivityCommand:Command{
    override fun name(): String {
        return "openPage"
    }

    override fun handleCommand(name: String, param: String) {
        val fromJson = Gson().fromJson(param, Map::class.java)

        val intent = Intent()
        intent.setComponent(ComponentName(MainApplication.mainApplication, fromJson["target_class"].toString()))
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        MainApplication.mainApplication.startActivity(intent)
    }
}